import json

import config


def w_data(name, data):
    with open(config.BASE_DIR + "/data/{}".format(name), "w", encoding="utf-8") as f:
        json.dump(data, f, ensure_ascii=False, indent=2)


def r_data(name):
    with open(config.BASE_DIR + "/data/{}".format(name), "r", encoding="utf-8") as f:
        return json.load(f)


if __name__ == '__main__':
    # banner_data = [[1, {'asserts': {'status_code': 200, 'name': '首页置顶'}}]]
    # ids_data = [[{"ids": "1,2,3"}, {'id': 1, 'name': '专题栏位一'}]]
    # category_id_data = [[{"id": "2"}, {"len": 8, 'id': 2, 'name': '梨花带雨'}]]
    # product_data = [[2, {'id': 2, 'name': '梨花带雨'}]]
    # order_id_data = [[{'id': '7'}, {'status_code': 200, 'id': 7}]]
    # w_data("order_data.json", order_id_data)
    create_order_data = [[{"products": [{"product_id": 8, "count": 1}, {"product_id": 10, "count": 2}],
                           'asserts': {"status_code": 200, 'pass': True}}]]
    # w_data('create_order_data.json', create_order_data)
    print(r_data('create_order_data.json'))
    # print(r_data('index_banner.json'))
    # print(r_data("index_theme.json"))
    # print(r_data("index_category.json"))
    # print(r_data("product_message.json"))
    # print(r_data('order_data.json'))
